<%--
  Created by IntelliJ IDEA.
  User: ZhuChunXiao
  Date: 2017/5/25
  Time: 15:23
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
  String path = request.getContextPath();
  String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>

<div id="page-content">
  <div class="row">

    <div class="col-lg-12">
      <div class="panel">
        <!--
        <div class="panel-heading">
          <h3 class="panel-title">步骤简要</h3>
        </div>
        -->
        <div class="panel-body">
          <div class="form-inline">
            <div class="row">
              <div class="col-sm-12 table-toolbar-left">
                <btn id="ajax_stepBrief_btn_add" class="btn btn-primary btn-sm">
                  <i class="ti-plus"> </i> 新建步骤简要表
                </btn>
              </div>
            </div>
          </div>
          <div class="table-jqgrid">
            <table id="ajax_stepBrief_table">
            </table>
            <div id="ajax_stepBrief_list_page">
            </div>
          </div>
        </div>
      </div>
    </div>
    <input type="hidden"  id="chooseId" />
  </div>
</div>



<script type="text/javascript">

  $(function(){
      load_stepBrief_jqGrid();
     // $("#ajax_stepBrief_list_row").width(table_global_width);
      $("#ajax_stepBrief_table").jqGrid('setGridWidth',  $('div').data("table_global_width"));
      $("#ajax_stepBrief_btn_add").click(function(){
          loadURL("<%=path%>/main/stepBrief/input?parentId="+$('#form_processBrief_input #keyId').val(), $('div#s2'));
      });
  });

  function load_stepBrief_jqGrid(){
      jQuery("#ajax_stepBrief_table").jqGrid({
          url:'<%=path%>/main/stepBrief/list?parentId='+$('#form_processBrief_input #keyId').val(),
          datatype: "json",
          loadonce: true,
          colNames:['步骤编号',"步骤名称","路由类型","下一步","操作","id"],
          colModel:[
              {name:'stepNo',index:'stepNo', width:50,sortable:false,search:false},
              {name:'name',index:'name',sortable:false,search:false,width:280},
              {name:'routeType',index:'routeType',sortable:false,search:false,width:100},
              {name:'nextStepNo',index:'nextStepNo',sortable:false,search:false,width:60},
              {name:'act',index:'act', width:210,sortable:false,search:false,fixed:true},
              {name:'id',index:'id',search:false,hidden:true,key:true}
          ],
          rowNum : 10,
          rowList:[10,20,30],
          pager : '#ajax_stepBrief_list_page',
          sortname : 'createTime',
          sortorder : "asc",
          gridComplete:function(){
              var ids=$("#ajax_stepBrief_table").jqGrid('getDataIDs');
              for(var i=0;i<ids.length;i++){
                  var cl=ids[i];
                  var rowData = $("#ajax_stepBrief_table").jqGrid("getRowData",cl);
                  var de="<button class='btn btn-default' data-original-title='编辑' onclick=\"fn_stepBrief_read('"+cl+"');\"><i class='fa fa-eye'></i>编辑</button>"+" ";
                  var dt="<button class='btn btn-default' data-original-title='删除' onclick=\"fn_stepBrief_destroy('"+cl+"');\"><i class='fa fa-eye'></i>删除</button>"+" ";
                  jQuery("#ajax_stepBrief_table").jqGrid('setRowData',ids[i],{act:de+dt});
              }
              $(".ui-jqgrid-bdiv").css("overflow-x","hidden");

          },
          onSelectRow: function (rowId, status, e) {
              var rowId = $("#ajax_stepBrief_table").jqGrid('getGridParam','selrow');
              var rowDatas = $("#ajax_stepBrief_table").jqGrid('getRowData', rowId);
              $('#chooseId').val(rowId);
          },
          jsonReader: {
              root: "dataRows",
              page: "page",
              total: "total",
              records: "records",
              repeatitems : false
          },
        //  caption : "<i class='fa fa-arrow-circle-right'></i> 步骤简要",
          multiselect : true,
          rownumbers:true,
          gridview:true,
          shrinkToFit:true,
          viewrecords: true,
          autowidth: true,
          height:'auto',
          forceFit:true,
          loadComplete: function() {
          }
      });

      jQuery("#ajax_stepBrief_table").jqGrid('filterToolbar',{searchOperators:false,stringResult:true});

      jQuery("#ajax_stepBrief_table").jqGrid('navGrid', "#ajax_stepBrief_list_page", {
          edit : false,
          add : false,
          del : false,
          search:false
      });
  };
      function fn_stepBrief_read(id){
          loadURL("<%=path%>/main/stepBrief/input?keyId="+id,  $('div#s2'));
      }


  function fn_stepBrief_destroy(id) {
    __confirm_dialog(null, '确定要删除吗?',
            function () {
              var url = "<%=path%>/main/stepBrief/delete/"+id;
              __ajax_post(url, null, function(pdata) {
                __toastr(pdata);
                jQuery("#ajax_stepBrief_table").jqGrid().setGridParam({datatype:'json'}).trigger("reloadGrid");
              });
            });
  }

</script>


